package com.rao.core.excel.typeHandler.impl;

import com.rao.core.excel.typeHandler.AbstractTypeHandler;
import org.apache.poi.ss.usermodel.Cell;

import java.lang.reflect.Field;
import java.util.Set;

/**
 * y轴为时间格式 yyyy/MM/dd
 */
public class DateTypeHandler extends AbstractTypeHandler {
    public DateTypeHandler(Set<Integer> columnIndexSet) {
        super(columnIndexSet);
    }

    @Override
    public boolean hand(Cell cell, int columnIndex, Field field, Object o) throws IllegalAccessException {
        if (this.columnIndexSet.contains(columnIndex)) {
            field.setAccessible(true);
            field.set(o, cell.getDateCellValue());
            return true;
        }
        return false;
    }
}
